package com.yanqu.road.server.cmd.activity;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityRewardResult;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.pb.activity.ActivityProto;
import com.yanqu.road.pb.crossunion.activity.CrossUnionActivityRankDataProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.pb.ActivityPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_SYNC_CROSS_UNION_RECHARGE_REWARD, desc = "获取活动奖励")
public class GetUnionREchargeActivityRewardFromCrossCmd extends AbstractCommand {



	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {

		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		CrossUnionActivityRankDataProto.CrossUnionRechargeGetRewardRespMsg resp = CrossUnionActivityRankDataProto.CrossUnionRechargeGetRewardRespMsg.parseFrom(packet.getBytes());
		int ret = resp.getRet();
		ActivityRewardResult result = new ActivityRewardResult();
		if (ret == 0) {
			int activityId = resp.getActivityId();
			int rewardCount = resp.getRewardCount();
			int conditionId = resp.getConditionId();
			 result = player.getModule(ActivityModule.class).getUnionRechargeActivityReward(activityId, conditionId, rewardCount);
		}else {
			result.setRet(ret);
		}
		ActivityProto.ActivityGetRewardRespMsg.Builder respMsg = ActivityPb.parseActivityGetRewardRespMsg(result);
		if(null != respMsg) {
			player.sendPacket(Protocol.U_ACTIVITY_GET_REWARD, respMsg);
		}
	}

	@Override
	public void sendData(GamePlayer player) {

	}

}
